import {
	html2json,
	json2html
} from 'html2json'
	import {
		nanoid
	} from "nanoid"
export default{
	getJson() {
	let html = '<title title="按钮 Button">'
	html +=
		'<el-button>Default</el-button><el-button type="primary">Primary</el-button><el-button type="success">Success</el-button><el-button type="info">Info</el-button><el-button type="warning">Warning</el-button><el-button type="danger">Danger</el-button>'
	html +=
		'<el-button plain>Plain</el-button><el-button type="primary" plain>Primary</el-button><el-button type="success" plain>Success</el-button><el-button type="info" plain>Info</el-button><el-button type="warning" plain>Warning</el-button><el-button type="danger" plain>Danger</el-button>'
	html +=
		'<el-button round>Round</el-button><el-button type="primary" round>Primary</el-button><el-button type="success" round>Success</el-button><el-button type="info" round>Info</el-button><el-button type="warning" round>Warning</el-button><el-button type="danger" round>Danger</el-button>'
	html +=
		'<el-button icon="el-icon-search" circle></el-button><el-button type="primary" icon="el-icon-edit" circle></el-button><el-button type="success" icon="el-icon-check" circle></el-button><el-button type="info" icon="el-icon-message" circle></el-button><el-button type="warning" icon="el-icon-star-off" circle></el-button><el-button type="danger" icon="el-icon-delete" circle></el-button>'
	html +=
		'<el-button type="primary" icon="el-icon-edit"></el-button><el-button type="primary" icon="el-icon-share"></el-button><el-button type="primary" icon="el-icon-delete"></el-button><el-button type="primary" icon="el-icon-search">搜索</el-button><el-button type="primary">上传<i class="el-icon-upload el-icon-right"></i></el-button>'
	html +=
		'<el-button type="primary" icon="el-icon-arrow-left" >上一页</el-button><el-button type="primary">下一页<i class="el-icon-arrow-right el-icon--right"></i></el-button>'
	html +=
		'<el-button type="primary" icon="el-icon-edit"></el-button><el-button type="primary" icon="el-icon-share"></el-button><el-button type="primary" icon="el-icon-delete"></el-button>'
	html += '<el-button size="medium">中等按钮</el-button><el-button size="small">小型按钮</el-button><el-button size="mini">超小按钮</el-button><el-button round>默认按钮</el-button><el-button size="medium" round>中等按钮</el-button><el-button size="small" round>小型按钮</el-button><el-button size="mini" round>超小按钮</el-button>'
	html += '</title>'
	let json = html2json(html)
	json.child.map((fv, fk) => {
		fv.attr.compId = nanoid()
		if (typeof fv.child != 'undefined') {
			fv.child.map((sv, sk) => {
				if (typeof sv.attr != 'undefined') {
					if (typeof sv.attr.size == 'undefined') {
						sv.attr.size = 'small'
					}
				}else{
					sv.attr = {size:'small'}
				}
			})
		}
	})
	return json.child
}
}
